<script type="text/javascript">
	
function lengthOfLongestSubstring(str) {
    let len = str.length;
    let record = {};        // 存放所有不重复的字符
    let max = 0;
    let l = 0, r = 0;      // 在[l...r]表示当前record的边界索引
    while(r < len) {
        if(record[str[r]]) {
            delete record[str[l++]];
        } else {
            record[str[r++]] = str[r];
            max = Math.max(r-l,max);
        }
    }

    return max;
}

let res = lengthOfLongestSubstring("a");
console.log(res);

</script>